package mortal.common.net
{
	import Engine.RMI.*;
	import Framework.Protocol.CDFProtocol.*;
	
	public class RMISession extends Object
	{
		private var _session:Session;
		private var _url:String;
		private var _comm:Communicator;
		
		public function RMISession()
		{
		}
		
		public function get session() : Session
		{
			return this._session;
		}
		
		public function set url(url:String) : void
		{
			if (this._url != url)
			{
				this._url = url;
				this._session = new Session();
				this.createCommunicator();
				this._session.bindCommunicator(this._comm);
			}
		}
		
		public function get url() : String
		{
			return this._url;
		}
		
		protected function createCommunicator() : Communicator
		{
			this._comm = CommunicatorManager.getInstance().createCommunicator(this._url, new GroupProtocol(new Protocol()));
			return this._comm;
		}
		
		public function registerProxy(proxy:RMIProxyObject) : void
		{
			proxy.bindingSession(this._session);
		}
		
	}
}
